package main

import (
	"fmt"
	"strconv"
	"time"
)

func test(str int) {
	for i := 0; i < 20; i++ {
		fmt.Println(strconv.Itoa(str) + "test输出 = " + strconv.Itoa(i))
		time.Sleep(time.Second * 1)
	}
}

// 启用多个协程遍历
func test2() {
	for i := 0; i < 10; i++ {
		go func(n int) {
			fmt.Println("test2输出 = " + strconv.Itoa(n))
			time.Sleep(time.Second * 1)
		}(i)
	}
}

func main() {
	go test(1) // 开启一个协程 ; 主死随从

	test2()

	for i := 0; i < 10; i++ {
		fmt.Println("主进程输出" + strconv.Itoa(i))
		time.Sleep(time.Second * 1)
	}

}
